import { createRouter, createWebHistory } from 'vue-router'
import LayoutIndex from '@/views/Layout/LayoutIndex.vue'
import LoginIndex from '@/views/Login/LoginIndex.vue'
import DeviceInfo from '@/views/Informations/DeviceInfo.vue'
import UserInfo from '@/views/Informations/UserInfo.vue'
import RoomInfo from '@/views/Informations/RoomInfo.vue'
import OrderInfo from '@/views/Informations/OrderInfo.vue'
import DataShowInfo from '@/views/Informations/DataShowInfo.vue'
import PayMoney from '@/views/Pay/PayMoney.vue'
import WaitPage from '@/components/WaitPage.vue'
import UserIndex from '@/views/User/UserIndex.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'layout',
      component: LayoutIndex,
      children: [
        {
          path: '',
          component: UserInfo,
        },
        {
          path: 'user',
          component: UserInfo,
        },
        {
          path: 'room',
          component: RoomInfo,
        },
        {
          path: 'order',
          component: OrderInfo,
        },
        {
          path: 'device',
          component: DeviceInfo,
        },
        {
          path: 'dataShow',
          component: DataShowInfo,
        },
      ]
    },
    {
      path: '/login',
      name: 'login',
      component: LoginIndex,
    },
    {
      path: '/payMoney',
      name: 'paymoney',
      component: PayMoney,
    },
    {
      path: '/waitPage',
      name: 'waitPage',
      component: WaitPage,
    },
    {
      path: '/userOrder',
      name: 'userOrder',
      component: UserIndex,
    },
    
  ]
})
//路由守卫
// router.beforeEach((to, from, next) => {
  // 从本地session查看是否登陆 
  // const isLoggedIn = checkLoggedInStatus() // 检查用户是否已登录

  // if (to.meta.requiresAuth && !isLoggedIn) {
  //   // 如果目标路由需要登录且用户未登录，则重定向至登录页
  //   next('/login');
  // } else {
  //   // 用户已登录或目标路由不需要登录，直接通过
  //   next();
  // }
// });
export default router
